package com.intellagric.controller.module.trace_process;


import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.TraceProcessQrcode;
import com.intellagric.service.traceability.trace_process.ProcessQrcodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2019/1/13
 * @DESC： 生产环节二维码管理
 */
@Controller
public class ProcessQrcodeController {

    @Autowired
    private ProcessQrcodeService processQrcodeService;

    /**
     * 添加生产流程二维码信息
     * @Param processQrcode
     * @return ResponseMessage
     */
    @RequestMapping("/process/qrcode/add")
    @ResponseBody
    public ResponseMessage add(TraceProcessQrcode processQrcode) {
        processQrcode.setId(UUID.randomUUID().toString().replaceAll("-",""));
        processQrcode.setCreateDate(new Date());
        processQrcode.setUpdateDate(new Date());
        return processQrcodeService.addProcessQrcode(processQrcode);
    }


    /**
     * 删除生产流程二维码信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/process/qrcode/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return processQrcodeService.deleteProcessQrcode(id);
    }

    /**
     * 修改生产流程二维码信息
     * @Param processQrcode
     * @return ResponseMessage
     */
    @RequestMapping("/process/qrcode/edit")
    @ResponseBody
    public ResponseMessage edit(TraceProcessQrcode processQrcode) {
        processQrcode.setUpdateDate(new Date());
        return processQrcodeService.editProcessQrcode(processQrcode);
    }

    /**
     * 查询生产流程二维码信息
     * @return TraceProcessQrcode
     */
    @RequestMapping("/process/qrcode/{id}")
    @ResponseBody
    public TraceProcessQrcode get(@PathVariable String id) {
        return processQrcodeService.getProcessQrcodeById(id);
    }


    /**
     * 查询生产流程二维码信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/process/qrcode/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return processQrcodeService.getProcessQrcodeList();
    }

    /**
     * 分页查询生产流程二维码信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/process/qrcode/query")
    @ResponseBody
    public LayuiDataGridResult getListByVo(TraceProcessQrcode processQrcode) {
        return processQrcodeService.getProcessQrcodeListByVo(processQrcode);
    }


}
